﻿using System.Collections.Generic;
using Lists = Algoritmia.DataStructures.Lists;
namespace Algoritmia.Problems.BinPacking
{
    public class NextFitBinPacker : IBinPacker
    {
        #region Implementation of IBinPacker

        public IEnumerable<int> Pack(Lists.IList<double> items, double capacity)
        {
            var capacityLeft = capacity;
            int bin = 0;
            foreach(var item in items)
            {
                if ( capacityLeft < item)
                {
                    capacityLeft = capacity;
                    bin++;
                }
                capacityLeft -= item;
                yield return bin;
            }
        }

        #endregion
    }    

}
